using System;
using libsvm;

namespace TestSvmPredict
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class TestSvmPredict
	{
		[STAThread]
		public static void  Main(System.String[] argv)
		{
			int i, predict_probability = 0;
		
			// parse options
			for (i = 0; i < argv.Length; i++)
			{
				if (argv[i][0] != '-')
					break;
				++i;
				switch (argv[i - 1][1])
				{
				
					case 'b': 
						predict_probability = svm_predict.atoi(argv[i]);
						break;
				
					default: 
						System.Console.Error.Write("unknown option\n");
						svm_predict.exit_with_help();
						break;
				
				}
			}
			if (i >= argv.Length)
				svm_predict.exit_with_help();
			try
			{
				//UPGRADE_TODO: Expected value of parameters of constructor 'java.io.BufferedReader.BufferedReader' are different in the equivalent in .NET. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1092"'
				System.IO.StreamReader input = new System.IO.StreamReader(argv[i]); // Input file
				System.IO.BinaryWriter output = new System.IO.BinaryWriter(new System.IO.FileStream(argv[i + 2], System.IO.FileMode.Create)); // Output file
				svm_model model = svm.svm_load_model(argv[i + 1]); // Model file
				new svm_predict().predict(input, output, model, predict_probability);
			}
			catch (System.IO.FileNotFoundException)
			{
				svm_predict.exit_with_help();
			}
			catch (System.IndexOutOfRangeException)
			{
				svm_predict.exit_with_help();
			}
		}
	}
}
